package org.zfes.snowier.cloud.zbss.widget.act.route.service.tea;

import java.util.Map;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.auth.shiro.util.SecurityUtil;
import org.zfes.snowier.cloud.zbss.widget.act.model.ActQuestionCategory;
import org.zfes.snowier.cloud.zbss.widget.act.service.IActQuestionCategoryService;
@Controller("org.zfes.snowier.cloud.zbss.widget.act.route.service.tea.actQuestionCategoryController") 
@RequestMapping("/active/service/tea/actQuestionCategory")
public class ActQuestionCategoryController extends BaseController {

	@Autowired
	private IActQuestionCategoryService actQuestionCategoryService;
	
    @RequestMapping(value="/loadActQuestionCategoryDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadActQuestionCategoryDataSet(@RequestParam Map<String,Object> params){
    	params.put("creatorUserId", SecurityUtil.getUserId().orElse(null));
    	params.put("status", Byte.valueOf("1"));
    	DataSet dataSet=  actQuestionCategoryService.loadActQuestionCategoryDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
    

    @RequestMapping(value="/createActQuestionCategory", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createActQuestionCategory(ActQuestionCategory actQuestionCategory){
		actQuestionCategoryService.createActQuestionCategory(actQuestionCategory);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	

    @RequestMapping(value="/loadActQuestionCategory", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadActQuestionCategory(Long id){
		Optional<ActQuestionCategory> ops = actQuestionCategoryService.loadActQuestionCategoryById(id);
		return ajaxQuery("actQuestionCategory",ops);
    }
	
	
    @RequestMapping(value="/updateActQuestionCategory", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateActQuestionCategory(ActQuestionCategory actQuestionCategory){
		actQuestionCategoryService.updateActQuestionCategory(actQuestionCategory);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	

    @RequestMapping(value="/deleteActQuestionCategory", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteActQuestionCategory(Long id){
		actQuestionCategoryService.deleteActQuestionCategory(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}